<?php
    session_start();
    error_reporting(0);
    include_once("checkAuthenticationAction.php");
    include_once("../service/articleService.php");
    include_once("../service/bannerService.php");
    include_once("../util/constant.php");
    $type = $_POST["type"];
    $event_id = $_POST["event"];
    $thumbnail = $_POST["thumbnail"];
    
    $result = createBanner($type,$event_id,$thumbnail);
    $new_id = mysql_insert_id();
    if($result){
        rename("../image/tmp/article/".session_id(), "../image/article/".$new_id);
        echo "<script>window.location.href='../admin/banner_detail.php?action=".EDIT_ACTION."&id=".$new_id."';</script>";    
    }else{
        echo "<script>window.location.href='../admin/banner_detail.php?action=".NEW_ACTION."';</script>";
    }
?>